﻿using FlyingEye.Common.Utils;
using FlyingEye.Models;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;

namespace FlyingEye.Services
{
    public class EncryptionMachineService : ITransientDependency
    {
        private readonly ApplicationConfiguration _applicationConfiguration;

        public EncryptionMachineService(ApplicationConfiguration applicationConfiguration)
        {
            _applicationConfiguration = applicationConfiguration;
        }

        public async Task<string> EncryptAsync(EncryptionMachineEncryptedModel model)
        {
            return await Task.FromResult(_applicationConfiguration.ConvertToEncryptedBase64String(model.Value));
        }

        public async Task<string> DecryptAsync(EncryptionMachineDencryptedModel model)
        {
            return await Task.FromResult(_applicationConfiguration.ConvertFromEncryptedBase64String(model.EncryptedBase64StringValue));
        }
    }
}
